package com.edu.exam.entity.examination.paper.technical;

import com.edu.exam.enums.examination.paper.SegmentationProcessingAlgorithm;
import com.edu.exam.enums.examination.paper.SegmentationProcessingStatus;
import jakarta.persistence.*;
import lombok.Data;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.Accessors;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;

/**
 * 智能切分配置实体类
 *
 * 根据E-04-04 智能切分子模块设计实现
 * 对应exam_segmentation_config数据表
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class SegmentationConfig {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /**
     * 配置名称
     */
    @Column(name = "config_name", nullable = false, length = 100)
    private String configName;

    /**
     * 配置描述
     */
    @Column(name = "config_description", length = 500)
    private String configDescription;

    /**
     * 切分算法类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "algorithm_type", nullable = false, length = 50)
    private SegmentationProcessingAlgorithm algorithmType;

    /**
     * 切分精度阈值
     */
    @Column(name = "precision_threshold", precision = 5, scale = 4)
    private Double precisionThreshold;

    /**
     * 置信度阈值
     */
    @Column(name = "confidence_threshold", precision = 5, scale = 4)
    private Double confidenceThreshold;

    /**
     * 最小区域宽度
     */
    @Column(name = "min_region_width")
    private Integer minRegionWidth;

    /**
     * 最小区域高度
     */
    @Column(name = "min_region_height")
    private Integer minRegionHeight;

    /**
     * 最大区域宽度
     */
    @Column(name = "max_region_width")
    private Integer maxRegionWidth;

    /**
     * 最大区域高度
     */
    @Column(name = "max_region_height")
    private Integer maxRegionHeight;

    /**
     * 边缘检测参数
     */
    @Column(name = "edge_detection_param", precision = 5, scale = 4)
    private Double edgeDetectionParam;

    /**
     * 区域合并参数
     */
    @Column(name = "region_merge_param", precision = 5, scale = 4)
    private Double regionMergeParam;

    /**
     * 噪声过滤参数
     */
    @Column(name = "noise_filter_param", precision = 5, scale = 4)
    private Double noiseFilterParam;

    /**
     * 是否启用模板匹配
     */
    @Column(name = "enable_template_matching")
    private Boolean enableTemplateMatching = false;

    /**
     * 模板匹配阈值
     */
    @Column(name = "template_matching_threshold", precision = 5, scale = 4)
    private Double templateMatchingThreshold;

    /**
     * 是否启用机器学习
     */
    @Column(name = "enable_machine_learning")
    private Boolean enableMachineLearning = false;

    /**
     * 机器学习模型路径
     */
    @Column(name = "model_path", length = 500)
    private String modelPath;

    /**
     * 配置状态
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "config_status", nullable = false, length = 20)
    private SegmentationProcessingStatus configStatus;

    /**
     * 配置版本号
     */
    @Column(name = "config_version", nullable = false)
    private Integer configVersion;

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(name = "created_time", nullable = false, updatable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(name = "updated_time")
    private LocalDateTime updatedTime;

    /**
     * 创建人
     */
    @Column(name = "created_by", length = 50)
    private String createdBy;

    /**
     * 更新人
     */
    @Column(name = "updated_by", length = 50)
    private String updatedBy;

    /**
     * 是否默认配置
     */
    @Column(name = "is_default")
    private Boolean isDefault = false;

    /**
     * 配置标签
     */
    @Column(name = "config_tags", length = 200)
    private String configTags;

    /**
     * 备注信息
     */
    @Column(name = "remarks", length = 1000)
    private String remarks;

    /**
     * 版本号（乐观锁）
     */
    @Version
    @Column(name = "version", nullable = false)
    private Long version = 0L;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;
}